/*
 * 
 *方法的整理与重构
 *
 *
 */
//定义app参数名称，并加载其它模块
var authApp=angular.module('authapp', ["ngCookies",'ngFileUpload','ui.bootstrap']);

//此为定位页面所用
authApp.value('page','observationTab');

/*controller部分*/
//主要操作controller
authApp.controller("observationTabController",function($scope,$http,$getQueryString,$location,$splice){
	//针对此页面需要的参数 should edit
	$scope.schoolPid=$getQueryString("pid");
	console.log($scope.schoolPid);
	
	//**********主体方法	
	
	/*
	 * 
	 * 其它操作方法
	 * 
	 */
	
	//添加机构信息
	$scope.addFirstZ=function(){
		if(window.confirm("是否确定保存？")){
			 var rJson={
					'schoolId':$scope.schoolPid, 
					'name':$scope.name,
					'classC':$scope.classC,
					'studentAmount':$scope.studentAmount,
					'teacher':$scope.teacher,
					'title':$scope.title,
					'age':$scope.age,
					'classCatagory':$scope.classCatagory,
					'techingSubject':$scope.techingSubject,
					'point1':$scope.point1,
					'point2':$scope.point2,
					'point3':$scope.point3,
					'point4':$scope.point4,
					'point5':$scope.point5,
					'opinion':$scope.opinion,
					'comprehensive':$scope.comprehensive,
					};
			$http({
				method:'post',
				url:apis.saveAuthExpertObservation,
				data:rJson,
			}).success(function(response){
				if(response.code=="000000"){

				}else{
					alert(response.errorMsg);
				}
			}).error(function(){
				alert("服务器打瞌睡了，请稍等！");
				
			})
		}
	}
	
	
	//根据id查询机构信息
	$scope.queryObservationInfo=function(pid){		
		var random=Math.random();
		var rJson={'schoolId':$scope.schoolPid,'random':random}
		$http({
			method:'get',
			url:apis.queryAuthExpertObservationInfo,
			params:rJson
		}).success(function(response){
			if(response.code=="000000"){
				$scope.schoolId=response.data.schoolId;
				$scope.name=response.data.name;
				$scope.classC=response.data.classC;
				$scope.studentAmount=response.data.studentAmount;
				$scope.teacher=response.data.teacher;
				$scope.title=response.data.title;
				$scope.age=response.data.age;
				$scope.classCatagory=response.data.classCatagory;
				$scope.techingSubject=response.data.techingSubject;
				$scope.point1=response.data.point1;
				$scope.point2=response.data.point2;
				$scope.point3=response.data.point3;
				$scope.point4=response.data.point4;
				$scope.point5=response.data.point5;
				$scope.opinion=response.data.opinion;
				$scope.comprehensive=response.data.comprehensive;
			}else{
				alert(response.errorMsg);
			}
		}).error(function(){
			alert("服务器打瞌睡了，请稍等！");
		})
	}
	
	//修改机构信息
	/*$scope.updateAuthSchoolInfoAccount=function(){
		if(window.confirm("是否确定修改？")){
			var rJson={'pid':$scope.Id,'account':$scope.account,'schoolname':$scope.schoolName,'major':$scope.major};
			console.log(rJson);
			$http({
				method:'post',
				url:apis.updateAuthSchoolInfoAccount,
				data:rJson,
			}).success(function(response){
				if(response.code=="000000"){
					$scope.isAddM=true;
					$scope.queryMain();
					$scope.account="";
					$scope.schoolName="";
					$scope.major="";
				}else{
					alert(response.errorMsg);
				}
			}).error(function(){
				alert("服务器打瞌睡了，请稍等！");
				$scope.isAddM=true;
			})
		}
	}*/
	
	$scope.turnTo=function(pid){
		location.href="observat.html";
	}
	
	$scope.queryObservationInfo();
})
